/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : main.h
  * @brief          : Header for main.c file.
  *                   This file contains the common defines of the application.
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2024 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* USER CODE END Header */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "stm32g0xx_hal.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "gpio.h"
/* USER CODE END Includes */

/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */

/* USER CODE END ET */

/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */

/* USER CODE END EC */

/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */

/* USER CODE END EM */

/* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void);

/* USER CODE BEGIN EFP */

/* USER CODE END EFP */

/* Private defines -----------------------------------------------------------*/
#define LCD_RST_Pin GPIO_PIN_13
#define LCD_RST_GPIO_Port GPIOC
#define LCD_CS_Pin GPIO_PIN_14
#define LCD_CS_GPIO_Port GPIOC
#define LCD_BL_Pin GPIO_PIN_15
#define LCD_BL_GPIO_Port GPIOC
#define SDA_SW_Pin GPIO_PIN_2
#define SDA_SW_GPIO_Port GPIOA
#define SDA_A0_Pin GPIO_PIN_3
#define SDA_A0_GPIO_Port GPIOA
#define SDA_A1_Pin GPIO_PIN_4
#define SDA_A1_GPIO_Port GPIOA
#define CH4_P_Pin GPIO_PIN_5
#define CH4_P_GPIO_Port GPIOA
#define CH4_N_Pin GPIO_PIN_1
#define CH4_N_GPIO_Port GPIOB
#define CH3_N_Pin GPIO_PIN_2
#define CH3_N_GPIO_Port GPIOB
#define CH3_P_Pin GPIO_PIN_10
#define CH3_P_GPIO_Port GPIOB
#define CH2_N_Pin GPIO_PIN_15
#define CH2_N_GPIO_Port GPIOB
#define CH2_P_Pin GPIO_PIN_8
#define CH2_P_GPIO_Port GPIOA
#define SCK_SW_Pin GPIO_PIN_10
#define SCK_SW_GPIO_Port GPIOA
#define CH1_N_Pin GPIO_PIN_11
#define CH1_N_GPIO_Port GPIOA
#define CH1_P_Pin GPIO_PIN_12
#define CH1_P_GPIO_Port GPIOA
#define SCK_A0_Pin GPIO_PIN_15
#define SCK_A0_GPIO_Port GPIOA
#define SCK_A1_Pin GPIO_PIN_0
#define SCK_A1_GPIO_Port GPIOD
#define KEY2_Pin GPIO_PIN_1
#define KEY2_GPIO_Port GPIOD
#define KEY1_Pin GPIO_PIN_2
#define KEY1_GPIO_Port GPIOD
#define EN5V_Pin GPIO_PIN_3
#define EN5V_GPIO_Port GPIOD
#define EN3V_Pin GPIO_PIN_4
#define EN3V_GPIO_Port GPIOB
#define ALERT_Pin GPIO_PIN_8
#define ALERT_GPIO_Port GPIOB
#define LCD_DC_Pin GPIO_PIN_9
#define LCD_DC_GPIO_Port GPIOB

/* USER CODE BEGIN Private defines */

#define CH1_P(i) HAL_GPIO_WritePin(CH1_P_GPIO_Port, CH1_P_Pin, (GPIO_PinState)i)
#define CH1_N(i) HAL_GPIO_WritePin(CH1_N_GPIO_Port, CH1_N_Pin, (GPIO_PinState)i)
#define CH2_P(i) HAL_GPIO_WritePin(CH2_P_GPIO_Port, CH2_P_Pin, (GPIO_PinState)i)
#define CH2_N(i) HAL_GPIO_WritePin(CH2_N_GPIO_Port, CH2_N_Pin, (GPIO_PinState)i)
#define CH3_P(i) HAL_GPIO_WritePin(CH3_P_GPIO_Port, CH3_P_Pin, (GPIO_PinState)i)
#define CH3_N(i) HAL_GPIO_WritePin(CH3_N_GPIO_Port, CH3_N_Pin, (GPIO_PinState)i)
#define CH4_P(i) HAL_GPIO_WritePin(CH4_P_GPIO_Port, CH4_P_Pin, (GPIO_PinState)i)
#define CH4_N(i) HAL_GPIO_WritePin(CH4_N_GPIO_Port, CH4_N_Pin, (GPIO_PinState)i)

#define EN5V(i) HAL_GPIO_WritePin(EN5V_GPIO_Port, EN5V_Pin, (GPIO_PinState)i)
#define EN3V(i) HAL_GPIO_WritePin(EN3V_GPIO_Port, EN3V_Pin, (GPIO_PinState)i)
#define SCK_A0(i)  HAL_GPIO_WritePin(SCK_A0_GPIO_Port, SCK_A0_Pin, (GPIO_PinState)i)
#define SCK_A1(i)  HAL_GPIO_WritePin(SCK_A1_GPIO_Port, SCK_A1_Pin, (GPIO_PinState)i)
#define SCK_SW(i)  HAL_GPIO_WritePin(SCK_SW_GPIO_Port, SCK_SW_Pin, (GPIO_PinState)i)
#define SDA_SW(i)  HAL_GPIO_WritePin(SDA_SW_GPIO_Port, SDA_SW_Pin, (GPIO_PinState)i)
#define SDA_A0(i)  HAL_GPIO_WritePin(SDA_A0_GPIO_Port, SDA_A0_Pin, (GPIO_PinState)i)
#define SDA_A1(i)  HAL_GPIO_WritePin(SDA_A1_GPIO_Port, SDA_A1_Pin, (GPIO_PinState)i)
                                                                
#define KEY1_READ()  HAL_GPIO_ReadPin(KEY1_GPIO_Port, KEY1_Pin)
#define KEY2_READ()  HAL_GPIO_ReadPin(KEY2_GPIO_Port, KEY2_Pin)
#define ALERT_READ() HAL_GPIO_ReadPin(ALERT_GPIO_Port, ALERT_Pin)


/* USER CODE END Private defines */

#ifdef __cplusplus
}
#endif

#endif /* __MAIN_H */
